package com.example.demo.kafka;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Created by Administrator on 2016/10/13.
 */
@RequestMapping("kafka")
@RestController
public class KafakaTest {
    @Autowired
    private KafkaProducerConfig kafkaProducerConfig;

    @RequestMapping(value = "a", method = RequestMethod.GET)
    public Object send (HttpSession session, HttpServletRequest request){
        try {
            int i = 0;
            for(int j =0;j<10;j++){
                kafkaProducerConfig.kafkaTemplate().send("topic1","msg"+i);
                i++;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}